<?php 

/**
 * 问题管理控制器
 * @author 阿柱 <422852954@qq.com>
 */
class AnswerController extends Controller{
    /**
     *   默认访问方法
     */
    public function index(){
    	$answer=$_GET['answer'];
		switch ($answer) {
			case 'all':
				$sql="SELECT * FROM hd_answer";
				break;
			case 'no':
				$sql="SELECT * FROM hd_answer WHERE accept=0";
				break;
			case 'yes':
				$sql="SELECT * FROM hd_answer WHERE accept=1";
				break;
		}
		$answerData=M()->query($sql);
		$this->assign('answerData',$answerData);
//		p($answerData);
		
       $this->display('answer.html'); 
    }
	
	/**
	 * 删除回答内容
	 */
	public function delete(){
//		删除回答
		$anid=intval($_GET['anid']);	
		$sql="DELETE FROM hd_answer WHERE anid={$anid}";
		M()->exec($sql);
//		给用户的回答数-1  金币-1，减经验-2(跟前台Ask控制器ask方法的值一一对应)
		$uid=intval($_GET['uid']);
		$sql="UPDATE hd_user SET answer=answer-1,point=point-1,exp=exp-2 WHERE uid={$uid}";
		M()->exec($sql);

//		$this->error('删除成功');
	}
	
	
 }
 

 
 
 
 
 
 









 ?>